﻿/*-----------------------------------
*定义通用查询使用
------------------------------------*/
//新增
//查询构建方法
var exp = [{ Text: "包含", Value: "like" }, { Text: "等于", Value: " = " }, { Text: "大于", Value: ">" }, { Text: "大于且等于", Value: ">=" }, { Text: "小于", Value: "<" }, { Text: "小于且等于", Value: "<=" }, { Text: "不等于", Value: "<>"}],
        arrOrAnd = [{ Text: " ", Value: " " }, { Text: "与", Value: "and" }, { Text: "或", Value: "or" }, {Text:"在..之间","between"}];

/*
构建查询条件
*/
var fnQueryBulider = function (clist) {
    return "";
}

/*
快搜
*/
var fnQucikQuery = function(key){
    return "";
}


//-------------------------------------------
//查询执行
//-------------------------------------------
var fnQueryRe = function (condition) {
    
    //alert("");
    if (typeof (fnCustomQueryRe) == "function") {
        fnCustomQueryRe(condition);
        return;
    } else {
        const_CustomCondition = condition;
        RefreshData();
    }
}



///-------------------------------------------
///快速搜索
///-------------------------------------------
var fnQuciklyQuery = function (keyword,AndOrFlagq) {
    
    if (const_QueryField == undefined || const_QueryField == "") {
        return;
    }
    var _keyword = document.getElementById("QueryContext").value;
    if (_keyword == "") {
        return;
    }
    var _chk = document.getElementById("checkAndOr").checked;
    //alert(_chk);
    var _opr = _chk ? " and " : " or ";
    //alert(_opr);
    var _fields = const_QueryField.split(",");
    var _keys = _keyword.split(" ");
    var _condition = "";
    for (n = 0; n < _keys.length; n++) {
        if (_keys[n] == "") {
            continue;
        }
        if (n == 0) {
            _condition = " ( "
        }
        else {
            _condition = _condition + _opr + " ( ";
        }
        for (i = 0; i < _fields.length; i++) {
            if (i == 0) {
                _condition = _condition + " (" + _fields[i] + " like '%" + _keys[n] + "%')  ";
            }
            else {
                _condition = _condition + " or (" + _fields[i] + " like '%" + _keys[n] + "%')  "
            }
        }
        _condition = _condition + " )";
    }
    //alert(_condition);
    fnQueryRe(encodeURI(_condition));
}
